#!/bin/sh
user_input_name=`basename $0`
code_src=$HOME/job/utf8_code/billing

if [ ! -n "$1" ] || [ "$1" == "help" ] || [ "$1" == "h" ];then
    printf "useage: %s component_name          have a look at Execute part,with cat\n" "$user_input_name"
    printf "        %s component_name v|vim    have a look at Execute part,with vim\n" "$user_input_name"
    exit
fi
component_name="$1"
#component_name=`echo $component_name | awk -F '_' '{print $*}'`
component_name=`echo $component_name | sed 's/_//g'`
printf "you search component name is: %s\n" "$1"
#result=`grep -r -i -w -n "$component_name::$component_name" $code_src | grep -v 'tags'`
result=`grep -r -i -w -n "$component_name::Execute" $code_src | grep -v -E 'tags|ADD_|.txt'`
printf "%s\n" "$result"
file_name=`echo $result | awk -F ':' '{print $1}'`
printf "%s\n" "$file_name"
echo "-----------------------$1-----------------------"
if [ -f $file_name ]; then
    if [ "$2" == "vim" ] || [ "$2" == "v" ]; then
        vim $file_name
    else
        cat -n $file_name
    fi
else
    printf "file [%s], not exist!\n" $file_name
fi
echo "-----------------------$1-----------------------"
exit 0



